package com.arron.jvm;

import java.util.UUID;

/**
 * @Classname HelloGc
 * @Date 2020/8/23 15:31
 * @Created by 刘
 *
 *
 *
 * 配置使用CMS收集器
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+PrintCommandLineFlags
 * 配置使用G1垃圾回收器
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+UseG1GC -XX:+PrintCommandLineFlags
 *---------------------------------------------------------------------------------------------
 * -Xms10m -Xmx10m -Xss1024k -XX:MetaspaceSize=521m -XX:+PrintGCDetails -XX:+UseSerialGC -XX:+PrintCommandLineFlags
 */
//protected,private不能修饰类
public class HelloGc {

    public static void main(String[] args) throws InterruptedException {

//        System.out.println("*******HelloGc");
//        Thread.sleep(Integer.MAX_VALUE);

//        HelloGc helloGc = new HelloGc();
//        helloGc.haha();
//        ArrayList<String> objects = new ArrayList<>();
//
//        String str1 = "hello";
//        String str2 = "hello";
//        char[] chr = {'h','e','l','l','o'};
//
//        System.out.println(str1 == str2);
        String str1 = "hello";
        String str2 = "word";
        String str3 = "helloword";
        System.out.println((str1+str2)==str3);
//        HelloGc helloGc = null;
//        helloGc.haha();
    }

    /**
     *产生的字符串常量是放在堆空间中
     */
    private static void haha() {
        int i = 0;
        try {
           String str="liuwei";
            while (true){
                str+= str + UUID.randomUUID().toString();
                i++;
            }
        }catch (Throwable e){
            e.printStackTrace();
        }finally {
            System.out.println("i="+i);
        }
    }

}
